package com.bw.zhuangao5___day002.Fragment.Movies.One;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bw.zhuangao5___day002.R;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * 类名： MoviesOne_Adoter
 * 作者： Android工程师杨晨
 * 日期： 2021/9/28 15:26
 * DAO：  ZhuanGao5___Day002
 */
public class MoviesOne_Adoter extends BaseMultiItemQuickAdapter<MoviesOne_JavaBen.DataBean, BaseViewHolder> {

    public MoviesOne_Adoter(@Nullable List<MoviesOne_JavaBen.DataBean> data) {
        super(data);
        addItemType(1, R.layout.moviesone_adpter1);
        addItemType(2, R.layout.moviesone_adpter2);
        addItemType(3, R.layout.moviesone_adpter3);

        addChildClickViewIds(R.id.moviesoneadpter1_Img);
        addChildClickViewIds(R.id.moviesoneadpter2_Img);
        addChildClickViewIds(R.id.moviesoneadpter3_Img);

        addChildLongClickViewIds(R.id.moviesoneadpter1_Img);
        addChildLongClickViewIds(R.id.moviesoneadpter2_Img);
        addChildLongClickViewIds(R.id.moviesoneadpter3_Img);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, MoviesOne_JavaBen.DataBean dataBean) {
        switch (dataBean.getItemType())
        {
            case 1:
                Glide.with(getContext()).load(dataBean.getPic())
                        .error(R.drawable.ic_launcher_background)//发起请求失败，一般撕裂
                        .into((ImageView) baseViewHolder.getView(R.id.moviesoneadpter1_Img));
                baseViewHolder.setText(R.id.moviesoneadpter1_text,dataBean.getTitle());
                break;

            case 2:
                Glide.with(getContext()).load(dataBean.getPic())
                        .error(R.drawable.ic_launcher_background)//发起请求失败，一般撕裂
                        .into((ImageView) baseViewHolder.getView(R.id.moviesoneadpter2_Img));
                baseViewHolder.setText(R.id.moviesoneadpter2_text,dataBean.getTitle());
                break;


            case 3:
                Glide.with(getContext()).load(dataBean.getPic())
                        .error(R.drawable.ic_launcher_background)//发起请求失败，一般撕裂
                        .into((ImageView) baseViewHolder.getView(R.id.moviesoneadpter3_Img));
                baseViewHolder.setText(R.id.moviesoneadpter3_text,dataBean.getTitle());
                break;
        }
    }
}
